<template>
  <div class="content_header_frame">
    <el-row style="height: 100%; cursor: default">
      <el-col class="middle-parent" :span="2"
        ><p style="text-align: center" class="middle-child" @click="toPageHead">首页</p></el-col
      >
      <el-col class="middle-parent" :span="2"
        ><p style="text-align: center" class="middle-child">帮助</p></el-col
      >
      <el-col class="middle-parent" :span="3" :offset="13"
        ><p style="text-align: center" class="middle-child">
          {{ timeString }}
        </p></el-col
      >
      <el-col  :span="2" style="overflow-x:hidden">
        <el-dropdown style="margin-left:60%" @command="handleMenuClick">
            <el-avatar
            :size="'small'"
            style=""
            :src="headUrl"
          ></el-avatar>
  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item command="notice">通知中心</el-dropdown-item>
  </el-dropdown-menu>
</el-dropdown>
     
      </el-col>
      <el-col class="middle-parent" :span="2"
        ><p
          style="text-align: center"
          class="middle-child"
          @click="showLeftPop"
        >
          <i class="el-icon-caret-left"></i></p
      ></el-col>
    </el-row>
  </div>
</template>

<script>
import { format } from "date-fns";
import { mapState ,mapActions} from "vuex";
export default {
  name: "ContentHeader",
  data() {
    return {
      timeString: "",
      it: null,
    };
  },
  mounted() {
    this.__init();
  },
  methods: {
    ...mapActions("appAbout",['openOtherApp']),
    showLeftPop() {
      this.$pubsub.publish("showLeftPop");
    },
    __init() {
      // 开始显示事件
      this.timeString = format(new Date(), "yyyy-MM-dd HH:mm:ss");
      this.it = setInterval(() => {
        this.timeString = format(new Date(), "yyyy-MM-dd HH:mm:ss");
      }, 1000);
    },

    handleMenuClick(val) {
        if(val=="notice"){
            this.openOtherApp('notice-view')
        }
    },
    toPageHead(){
      this.$router.push({
        name:'index'
      })
    }
  },
  beforeDestroy() {
    if (this.it) window.clearInterval(this.it);
  },
  computed: {
    ...mapState("userAbout", ["userPersonality"]),
    headUrl() {
      if (this.userPersonality) {
        return `http://172.30.233.181:9001/oss/icons/${this.userPersonality.userHeadsPath}`;
      } else {
        return "";
      }
    },
  }
};
</script>

<style scoped lang="less">
.content_header_frame {
  z-index: 2000;
  height: 100%;
}
/deep/.el-col {
  opacity: 1;
  color: black;
  height: 100%;
  color: white;
  overflow-y: hidden;
  padding: none;
}
/deep/.el-col:hover {
  background-color: black;
}
</style>